package com.web.kongjian.ao.utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

import org.apache.commons.io.IOUtils;

import com.base.data.exception.DataException;


public class PictureUtils
{
	public static void copyPicture(String filePath,String targetFilePath,int zoomWidth,int zoomHeight)
	{	
		File newFile = new File(targetFilePath);
		File oldFile = new File(filePath);
		FileInputStream inStream = null;
		FileOutputStream outStream = null;
		int byteReader = 0;
		
		if(newFile.exists ())
		{
			throw new DataException(newFile+"�Ѿ����ڣ�");
		}
		if(oldFile.exists ())
		{
			try
			{
				inStream = new FileInputStream(filePath);
				outStream = new FileOutputStream(targetFilePath);
				
				byte[] buffer = new byte[2048];
				
				while((byteReader=inStream.read (buffer))!=-1)
				{
					outStream.write (buffer ,0 ,byteReader);
				}
				
				
				
			}catch (Exception e)
			{
				e.printStackTrace();
			}
			finally
			{
				IOUtils.closeQuietly (inStream);
				IOUtils.closeQuietly (outStream);
			}
		}
	} 
	
	public static void main(String args[])
	{
		
		copyPicture("C:\\Users\\Wulianwang\\Desktop\\lol.jpg","C:\\Users\\Wulianwang\\Desktop\\lol_3.jpg",0,0);
		
	}
	
}
